package com.example.zqm.git72.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;

import com.example.zqm.git72.Adapter.CollectionclubAdapter;
import com.example.zqm.git72.JavaBean.Collection;
import com.example.zqm.git72.Model.CollectionModel;
import com.example.zqm.git72.R;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class CollectClubActivity extends AppCompatActivity {
    List<Collection> collections;
    RecyclerView recyclerView;
    String user_id;
    //String id;
    Collection collection;
    //private Button btn_cancel;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_collectclub);
        recyclerView = (RecyclerView) findViewById(R.id.collectclub);
        recyclerView.setLayoutManager(new LinearLayoutManager(CollectClubActivity.this));//设置布局
        shouData();
        //btn_cancel=(Button)findViewById(R.id.btn_cancel);
        //initGG();
    }


    private void shouData() {
        //System.err.println("id =" + id);
        SharedPreferences sharedPreferences=getSharedPreferences("userInfo", Context.MODE_PRIVATE);
        user_id=sharedPreferences.getString("user_id","");
        CollectionModel collectionModel = new CollectionModel();
        Call<List<Collection>> call = collectionModel.getListclub(user_id,"1");
        call.enqueue(new Callback<List<Collection>>() {
            @Override
            public void onResponse(Call<List<Collection>> call, Response<List<Collection>> response) {
               collections=response.body();
               recyclerView.setAdapter(new CollectionclubAdapter(CollectClubActivity.this, collections));//设置适配器

                //System.err.println("club course ok");
            }

            @Override
            public void onFailure(Call<List<Collection>> call, Throwable t) {

            }
        });
    }
//    public  void  initGG(){
//        btn_cancel.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//            }
//        });
//    }
}
